<?php

/***************************************************************************
 *   Copyright (C) 2006 by Fernando Lagos <fernando@zerial.org> 	   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

require("core/SapormTable.class.php");
require("core/MySQL.class.php");
require("core/PostgreSQL.class.php");
require("core/Oracle.class.php");

class SapormCore{
	public $model_dir;
	public $dbtype;
	public $socket;
	public $table_name;
	public $result;
	function __construct(){
		$this->model_dir = "model";
	}
	function init($_dbtype, $_username, $_password, $_host = "localhost", $_port = 3306){
		$this->dbtype = strtolower($_dbtype);
		switch($this->dbtype){
		case 'mysql':
			$this->socket = new MySQL($_username, $_password, $_host, $_port);
			break;
		case 'postgresql':
			break;
		case 'oci8':
			break;
		}
	}
	function database($_dbname){
		$this->socket->database($_dbname);
	}
/*	function loadData($_limit = NULL){
		$this->socket->loadData($this, $_limit);
	}
	function search($_pattern){
		return $this->socket->search($_pattern, $this);
	}
 */
	/**
	 * function loadModel(): Load tables into $model_dir directory
	 *
	 */
	function loadModel(){
		$this->socket->loadModel($this);
	}
	function setValue($_values = array()){
		$this->socket->setValue($_values);
	}

}
?>
